package com.yf1706.dao.jpa;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.yf1706.bean.Emp;
import com.yf1706.vo.EmpSSVO;

public interface IEmpJDAO extends CrudRepository<Emp, Integer>{
	public Emp findByEmpId(int empId);
	
	//根据员工ID查询具体员工
	@Query("select e from Emp e inner join PostSetting p on e.postSetting.postId=p.postId "
			+ "inner join RankSetting r on r.rankId=e.rankSetting.rankId "
			+ "inner join Dep d on d.depId=e.dep.depId where e.empId=:empId")
	public Emp findBasicByEmpId(@Param("empId")int empId);
	
	//根据部门ID查找员工
	@Query("select e from Emp e where e.dep.depId=:depId")
	public List<Emp> findBasicByDepId(@Param("depId")int depId);
	/**
	    * 用于员工端登陆
	 */
	@Query(value = "SELECT e FROM Emp e where e.empId=?1 and e.password=?2")
	public Emp findBylogin(int empid,String password);
	
	@Query("SELECT new com.yf1706.vo.EmpSSVO(e.empId, e.empName) FROM Emp e where e.dep.depId = ?1")
	public List<EmpSSVO> findEmpByDepID(int did);
}